package com.truckdispatching.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class CarTypeUtil {
	
	private static Map<String, String> typeMap = new HashMap<String, String>();
	
	static {
		typeMap.put("半挂车","TT_SEMI");
		typeMap.put("冷藏车","TT_REFRIGER");
		typeMap.put("保温车","TT_INSULATED");
		typeMap.put("高栏车","TT_HIGHHURDLE");
		typeMap.put("平板车","TT_FLAT");
		typeMap.put("前四后八","TT_F4L8");
		typeMap.put("前四后四","TT_F4L4");
		typeMap.put("前四后十","TT_F4L10");
		typeMap.put("集装箱","TT_CONTAINER");
		typeMap.put("普通车","TT_COMMON");
		typeMap.put("敞篷车","TT_CABRIO");
	}
	
	public static List<String> getTypeNameList() {
		Set<String> names = typeMap.keySet();
		List<String> list  = new ArrayList<String>();
		list.addAll(names);
		return list;
	}
	
	public static String getTypeCode(String name) {
		return typeMap.get(name);
	}
	
	public static String getTypeName(String code) {
		Set<String> key = typeMap.keySet();
        for (Iterator<String> it = key.iterator(); it.hasNext();) {
        	String name = it.next();
            String value = typeMap.get(name);
            if (value != null && value.equals(code))
            	return name;
        }
        return null;
	}

}
